import java.util.ArrayList;
import java.util.List;

/**
 * 学院类
 */
public class School {
    private String name;
    private List<Department> departments = new ArrayList<>(); // 1到多个系
    private List<Student> students = new ArrayList<>(); // 0到多名学生

    // 添加系（1到多）
    public void addDepartment(Department department) {
        departments.add(department);
    }

    // 添加学生（0到多）
    public void addStudent(Student student) {
        students.add(student);
    }
}

/**
 * 系类
 */
public class Department {
    private String name;
    private List<Instructor> instructors = new ArrayList<>(); // 至少1位教师
    private List<Subject> subjects = new ArrayList<>(); // 至少1门课程

    // 添加教师（至少1位）
    public void addInstructor(Instructor instructor) {
        instructors.add(instructor);
        instructor.setDepartment(this); // 教师关联系
    }

    // 添加课程（至少1门）
    public void addSubject(Subject subject) {
        subjects.add(subject);
    }
}

/**
 * 教师类
 */
public class Instructor {
    private String name;
    private Department department; // 所属系（至少1个）
    private List<Subject> taughtSubjects = new ArrayList<>(); // 1-3门课程

    // 设置所属系
    public void setDepartment(Department department) {
        this.department = department;
    }

    // 教授课程（1-3门）
    public void addTaughtSubject(Subject subject) {
        if (taughtSubjects.size() < 3) { // 限制最多3门
            taughtSubjects.add(subject);
        }
    }
}

/**
 * 课程类
 */
public class Subject {
    private String name;
}

/**
 * 学生类
 */
public class Student {
    private String name;
    private List<Subject> attendedSubjects = new ArrayList<>(); // 1-5门课程

    // 参加课程（1-5门）
    public void attendSubject(Subject subject) {
        if (attendedSubjects.size() < 5) { // 限制最多5门
            attendedSubjects.add(subject);
        }
    }
}